﻿using System;
using System.Data;
using System.Web;
using Ajax.Tools;
using System.IO;
namespace Ajax.Web.Admin.Black
{
    public partial class Edit : Ajax.Tools.ManagePage
    {
        public int editid;    //ID
        protected void Page_Load(object sender, EventArgs e)
        {
            chkLoginLevel("editChannel");
            //取得栏目传参
            if (int.TryParse(Request.Params["editid"], out editid) == true)
            {
                if (!Page.IsPostBack)
                {
                    switch (editid)
                    {
                        case 1:
                            System.IO.StreamReader my1 = new StreamReader(Server.MapPath("~/Control/Top.ascx"), System.Text.Encoding.Default);
                            this.FCKeditor.Value = my1.ReadToEnd();
                            my1.Close();
                            break;
                        case 2:
                            System.IO.StreamReader my2 = new StreamReader(Server.MapPath("~/Control/Footer.ascx"), System.Text.Encoding.Default);
                            this.FCKeditor.Value = my2.ReadToEnd();
                            my2.Close();
                            break;
                        case 3:
                            System.IO.StreamReader my3 = new StreamReader(Server.MapPath("~/Control/rightweb.ascx"), System.Text.Encoding.Default);
                            this.FCKeditor.Value = my3.ReadToEnd();
                            my3.Close();
                            break;
                        default:
                            JscriptMsg(350, 230, "错误提示", "<b>出现错误啦！</b>您要编辑类别的种类不明确或参数不正确。", "back", "Error");
                            break;
                    }
                }
            }
            else
            {
                JscriptMsg(350, 230, "错误提示", "<b>出现错误啦！</b>您要修改类别的种类不明确或参数不正确。", "back", "Error");
            }
        }

        //保存修改
        protected void btnSave_Click(object sender, EventArgs e)
        {
            switch (editid)
            {
                case 1:
                    System.IO.StreamWriter sw1 = new StreamWriter(Server.MapPath("~/Control/Top.ascx"), false, System.Text.Encoding.Default);
                    sw1.Write(this.FCKeditor.Value);
                    sw1.Close();
                    break;
                case 2:
                    System.IO.StreamWriter sw2 = new StreamWriter(Server.MapPath("~/Control/Top.ascx"), false, System.Text.Encoding.Default);
                    sw2.Write(this.FCKeditor.Value);
                    sw2.Close();
                    break;
                case 3:
                    System.IO.StreamWriter sw3 = new StreamWriter(Server.MapPath("~/Control/Top.ascx"), false, System.Text.Encoding.Default);
                    sw3.Write(this.FCKeditor.Value);
                    sw3.Close();
                    break;
                default:
                    JscriptMsg(350, 230, "错误提示", "<b>出现错误啦！</b>您要编辑类别的种类不明确或参数不正确。", "back", "Error");
                    break;
            }
            JscriptPrint("类别修改成功啦！", "Edit.aspx?editid=" + editid, "Success");
        }

    }
}
